package ru.amse.ilyin.diagram.impl;

import java.awt.Point;

import ru.amse.ilyin.analyzer.Package;
import ru.amse.ilyin.diagram.Renderer;

/**
 * Graphical representation of a package.
 *
 * @author Alexander Ilyin
 */
public class PackageElement extends AbstractElement {
	private static final int LENGTH = 20;
	
	private final Package aPackage;
	
	/**
	 * Creates new element of a package diagram.
	 * 
	 * @param aPackage package
	 */
	public PackageElement(Package aPackage) {
		this.aPackage = aPackage;
	}
	
	@Override
	public String getName() {
		return aPackage.getName();
	}

	@Override
	public Point getCenter() {
		return new Point(getLocation().x + LENGTH / 2, getLocation().y + LENGTH / 2);
	}

	public void draw(Renderer renderer) {
		renderer.drawRectangle(getLocation().x, getLocation().y, LENGTH, LENGTH);
		renderer.drawString(getName(), getLocation().x, getLocation().y);
	}
}
